﻿/* 
 * TABLE: dbo.Ratings 
 */

/* 
 * TABLE: Ratings 
 */

CREATE TABLE Ratings(
    UserId    int    NOT NULL,
    Value     int    NOT NULL,
    BookId    int    NOT NULL,
    CONSTRAINT PK_Ratings PRIMARY KEY NONCLUSTERED (UserId, BookId)
)
GO
ALTER TABLE Ratings ADD CONSTRAINT FKUsers_Ratings 
    FOREIGN KEY (UserId)
    REFERENCES Users(UserId)
GO
/* 
 * TABLE: dbo.Ratings 
 */

/* 
 * TABLE: Ratings 
 */

ALTER TABLE Ratings ADD CONSTRAINT FKBooks_Ratings 
    FOREIGN KEY (BookId)
    REFERENCES Books(BookId)